import Vue from 'vue'
import App from './App.vue'
import { router } from './router'
import store from './store'
import 'normalize.css/normalize.css'
import Element from 'element-ui'
import Message from 'vue-m-message'
import 'xe-utils'
import i18n from '@/i18n'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'
import Katex from '@/common/katex'
import VueParticles from 'vue-particles'
import VueClipboard from 'vue-clipboard2'
import Md_Katex from '@iktakahiro/markdown-it-katex'
import highlight from '@/common/highlight'
import axios from 'axios'
import filters from '@/common/filters.js'

import '@/styles/index.scss' // global css
import './icons' // icon
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style

import 'element-ui/lib/theme-chalk/index.css'



//  markdown编辑器
import mavonEditor from 'mavon-editor'  //引入markdown编辑器
import 'mavon-editor/dist/css/index.css';
Vue.use(mavonEditor)
// Vue.use(Md_Katex)
// mavonEditor.markdownIt.use(Md_Katex) // 挂载到vue
// mavonEditor.markdownIt.set({}).use(Md_Katex);
Vue.prototype.$markDown = mavonEditor

// Vue.use(Element, {
//   size: 'medium' // set element-ui default size
// })
Vue.use(Message, { name: 'msg' }) // `Vue.prototype.$msg` 全局消息提示

NProgress.configure({ showSpinner: false }) // NProgress Configuration

router.beforeEach(async (to, from, next) => {
  // start progress bar
  NProgress.start()
  if (to.meta.title !== undefined) {
    document.title = to.meta.title
  } else {
    document.title = '\u200E'
  }
  // store.commit('router/initRoutes')

  if (to.path) {
    // eslint-disable-next-line no-undef
    _hmt.push(['_trackPageview', '/#' + to.fullPath])
  }

  next()
})

Object.keys(filters).forEach(key => {   // 注册全局过滤器
  Vue.filter(key, filters[key])
})
Vue.use(VueParticles) // 粒子特效背景
Vue.use(Katex)  // 数学公式渲染
VXETable.setup({
  // 对组件内置的提示语进行国际化翻译
  i18n: (key, value) => i18n.t(key, value)
})
Vue.use(VXETable) // 表格组件
Vue.use(VueClipboard) // 剪贴板
Vue.use(highlight) // 代码高亮
Vue.use(Element,{
  i18n: (key, value) => i18n.t(key, value)
})

router.afterEach((to, from, next) => {
  // finish progress bar
  NProgress.done()
})

Vue.prototype.$$router = router
Vue.prototype.$axios = axios

Vue.config.productionTip = false

new Vue({
  router,
  i18n,
  store,
  render: h => h(App)
}).$mount('#app')
